/*
 * @Description: 创建用于管理拖拽按钮状态的Context
 * @Author: Caroline
 * @Date: 2024-06-22 17:49:22
 * @LastEditTime: 2024-06-22 17:59:24
 * @LastEditors: Caroline
 * @FilePath: \education-offical--web\src\components\DraggableButton\DragButtonContext.jsx
 */
import React, { createContext, useContext, useState } from 'react';

// 创建Context，不使用类型定义
const DragButtonContext = createContext({
  buttonPosition: { x: 0, y: 0 },
  setButtonPosition: () => {},
});

// 自定义Hook，用于消费Context
const useDragButtonState = () => useContext(DragButtonContext);

// 创建Context Provider组件
const DragButtonContextProvider = ({ children }) => {
  const [buttonPosition, setButtonPosition] = useState({ x: 0, y: 0 });

  return (
    <DragButtonContext.Provider value={{ buttonPosition, setButtonPosition }}>
      {children}
    </DragButtonContext.Provider>
  );
};



export { DragButtonContextProvider, useDragButtonState };